package com.codejiwei.core.rdd

import org.apache.spark.{SparkConf, SparkContext}

object Spark_Operator_Repartition {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[1]").setAppName("Repartition")
    val sc = new SparkContext(conf)
    val rdd = sc.makeRDD(List(1, 2, 3, 4, 5, 6), 2)

    //TODO repartition扩大分区
    //扩大分区，repartition底层其实就是调用了coalesce()
    val rdd1 = rdd.repartition(3)

    rdd1.saveAsTextFile("output")
    sc.stop()
  }
}
